let classModel = require('./model/classModel');

let delClassByIdController = async (id) => {
    let result = await classModel.deleteOne({ _id: id });
    return result;
}
let findClassByNameController = async (name) => {
    let result = await classModel.find({ name });
    return result;
}
let findClassByNameFilterController = async (name) => {
    let results = await classModel.find({ name:{$regex:name} });
                                   //属性     正则    实际的内容 开发     
    return results;
}

let findClassByIdController = async (id) => {
    let result = await classModel.findOne({ _id: id });
    return result;
}
let addClassController = async (name) => {
    let result = await classModel.create({ name })
    return result;
}

let updateClassController = async (id,name) => {
    let result = await classModel.updateOne({_id: id},{name})
    return result;
}
module.exports = {
    delClassByIdController,
    addClassController,
    findClassByNameController,
    updateClassController,
    findClassByIdController,
    findClassByNameFilterController
}